interface Styles {
    bold?: string | string[];
    italic?: string | string[];
    underline?: string | string[];
    inverse?: string | string[];
    strikethrough?: string | string[];
    white?: string | string[];
    grey?: string | string[];
    black?: string | string[];
    blue?: string | string[];
    cyan?: string | string[];
    green?: string | string[];
    magenta?: string | string[];
    red?: string | string[];
    yellow?: string | string[];
    whiteBG?: string | string[];
    greyBG?: string | string[];
    blackBG?: string | string[];
    blueBG?: string | string[];
    cyanBG?: string | string[];
    greenBG?: string | string[];
    magentaBG?: string | string[];
    redBG?: string | string[];
    yellowBG?: string | string[];
}

type StylesRequired = {
    [p in keyof Styles]-?: string
}



var styles: Styles = {
    bold: ["\x1B[1m", "\x1B[22m"],
    italic: ["\x1B[3m", "\x1B[23m"],
    underline: ["\x1B[4m", "\x1B[24m"],
    inverse: ["\x1B[7m", "\x1B[27m"],
    strikethrough: ["\x1B[9m", "\x1B[29m"],
    white: ["\x1B[37m", "\x1B[39m"],
    grey: ["\x1B[90m", "\x1B[39m"],
    black: ["\x1B[30m", "\x1B[39m"],
    blue: ["\x1B[34m", "\x1B[39m"],
    cyan: ["\x1B[36m", "\x1B[39m"],
    green: ["\x1B[32m", "\x1B[39m"],
    magenta: ["\x1B[35m", "\x1B[39m"],
    red: ["\x1B[31m", "\x1B[39m"],
    yellow: ["\x1B[33m", "\x1B[39m"],
    whiteBG: ["\x1B[47m", "\x1B[49m"],
    greyBG: ["\x1B[49;5;8m", "\x1B[49m"],
    blackBG: ["\x1B[40m", "\x1B[49m"],
    blueBG: ["\x1B[44m", "\x1B[49m"],
    cyanBG: ["\x1B[46m", "\x1B[49m"],
    greenBG: ["\x1B[42m", "\x1B[49m"],
    magentaBG: ["\x1B[45m", "\x1B[49m"],
    redBG: ["\x1B[41m", "\x1B[49m"],
    yellowBG: ["\x1B[43m", "\x1B[49m"],
};

function hasOwnProperty<T, K extends PropertyKey>(obj: T, prop: K): obj is T & Record<K, unknown> {
    return Object.prototype.hasOwnProperty.call(obj, prop);
}

export function getClgStyly() {
    let obj: Styles = {}
    for (const key in styles) {
        //@ts-ignore
        obj[key] = styles[key].join("%s")
    }
    return obj as StylesRequired
}

export const clgLogStyles = getClgStyly()
